#include "windows.h"
#include "stdio.h"
#include "CGame.h"
#include "CStateManagement.h"
#include "conio.h"
#include "CFpsController.h"
namespace Framework
{
	CGame::CGame():m_eStatus(INIT)
	{
		SetInstance(this);
		CFpsController::GetInstance()->SetLimitFPS(40);
	}
	void CGame::Pause()
	{
		m_eStatus=PAUSED;
	}
	void CGame::Resume()
	{
		m_eStatus=RUNNING;
	}
	void CGame::Exit()
	{
		m_eStatus=EXIT;
	}
	void CGame::Update()
	{
		switch(m_eStatus)
		{
		case INIT:
			this->Init();
			m_eStatus=RUNNING;
			break;
		case RUNNING:
		case PAUSED:
			CFpsController::GetInstance()->BeginCounter();
			CStateManagement::GetInstance()->Update(m_eStatus==PAUSED);
			CFpsController::GetInstance()->EndCounter();
			break;
		case EXIT:
			CStateManagement::GetInstance()->SwitchState(0);
			CStateManagement::GetInstance()->Update(false);
			Destroy();	
			break;
		}
	}	
}